<?php

require_once("db.inc.php");
require_once("common.inc.php");
require_once("queries.inc.php");

auth();
$dbh = get_db();

initSession();

xmlhead("WikiVocabularyTrainer - Wordgroup cleanup");

?>
<body>
<?php

$query = do_query("
	SELECT expression_id, s.syntrans_sid, ws.wordgroup_id
	FROM wvt_wordgroup_subscriptions wsub, wvt_wordgroup_syntranses ws
	LEFT JOIN uw_syntrans s
	ON ws.syntrans_sid = s.syntrans_sid
	WHERE s.remove_transaction_id IS NOT NULL
	AND wsub.wordgroup_id = ws.wordgroup_ID
	AND wsub.user_id = {$_SESSION['user_id']}
", $dbh);

while ($row = mysql_fetch_array($query)) {
	$query = do_query("
	SELECT spelling
	FROM uw_expression
	WHERE expression_id = {$row['expression_id']}
", $dbh);
	while ($subrow = mysql_fetch_array($query)) {
		echo "{$subrow['spelling']} ({$row['expression_id']}) is no longer with us (syntrans {$row['syntrans_sid']})!<br />";
	}
}

?>

TODO: add interaction options (delete [easy], find alternative [hard])

</body>
</html>